#ifndef __THREAD_POOL__
#define __THREAD_POOL__
#include "head.h"
#include "tidArr.h"
#include "taskQueue.h"
#include "protocol.h"
#include "fileCommand.h"
#include "dataBase.h"
#include <search.h>
#include "hashSet.h"
#include <errno.h>
#include "login_register.h"
#include "token.h"
#include "fileTransfer.h"
#define TOKEN_LENGTH 128  // 定长Token的Base64编码长度
#define MAX_BUF_LEN 4096  // 最大数据长度限制


typedef struct threadPool_s {
    // 子线程的信息 
    tidArr_t tidArr;
	// 任务队列，上传下载
    taskQueue_t taskQueueLong;
	// 锁
    pthread_mutex_t mutex;
    // 条件变量，上传下载
    pthread_cond_t condLong;
    // 退出标志
    int exitFlag;
} threadPool_t;


int threadPoolInit(threadPool_t *pthreadPool,int workerNum);
int makeWorker(threadPool_t *pthreadPool);
int tcpInit(char *ip, char *port);
int epollAdd(int epfd, int fd);
int epollDel(int epfd, int fd);
int transfile(int sockfd);
int sendCommand(int sockfd,CommandType_e cmd,ResponseResults_e res,const char *data,size_t data_length);

// int recvCommand(int sockfd, CommandType_e *cmd, char *token, char *buf, int *buf_len);
int recvCommand(int sockfd, protocol_header_t *header, char *buf, size_t buf_size);
int generateSalt(char *salt);
void drawBanner(); 
void processShortCommand(int netfd, CommandType_e cmd, char *data,filePath_t* file_path);
#endif

